import matplotlib
matplotlib.use('TkAgg')
import cv2
import numpy as np
import matplotlib.pyplot as plt

# 读取图像
file_path = '../photo2.jpeg'  # 替换为实际的图像路径
img = cv2.imread(file_path)

# 应用均值滤波
blur = cv2.blur(img, (5, 5))

# 显示结果
plt.subplot(121), plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(cv2.cvtColor(blur, cv2.COLOR_BGR2RGB))
plt.title('Blurred Image'), plt.xticks([]), plt.yticks([])
plt.show()